home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Window / c / CreateOrig < prev    next >
Text File  |  1995-07-21  |  2KB  |  69 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Window.CreateOrig.c
  12.     Author:  Copyright © 1995 Sergio Monesi (original code from
  13.                               Window.Create.c by Jason Williams)
  14.     Version: 1.00 (15 Feb 1995)
  15.     Purpose: High-level window management functions: Create a window
  16.              without making a copy of the template (ie. use the original
  17.              template)
  18. */
  19.  
  20.  
  21. #include "DeskLib:LinkList.h"
  22. #include "DeskLib:WimpSWIs.h"
  23. #include "DeskLib:Template.h"
  24. #include "DeskLib:Event.h"
  25. #include "DeskLib:Window.h"
  26. #include "DeskLib:Screen.h"
  27. #include "DeskLib:Error.h"
  28.  
  29. #include "WindowDefs.h"
  30.  
  31. #include <stdlib.h>
  32. #include "string.h"
  33.  
  34.  
  35. #define ERRBASE 1
  36. #define ERR1 ERRBASE+0
  37. #define ERRMESS1 "Insufficient memory to open window"
  38.  
  39.  
  40. extern linklist_header window_listanchor;
  41.  
  42.  
  43. extern window_handle Window_CreateOrig(char *windowname)
  44. {
  45.   windowrec     *record;
  46.   window_block  *windowptr;
  47.   window_handle window;
  48.  
  49.   windowptr = Template_Find(windowname);
  50.   if (windowptr == NULL)
  51.     return(0);
  52.  
  53.   Wimp_CreateWindow(windowptr, &window);
  54.  
  55.   record = (windowrec *) malloc(sizeof(windowrec));
  56.   if (record == NULL)  Error_ReportFatalInternal(ERR1, ERRMESS1);
  57.  
  58.   LinkList_AddToHead(&window_listanchor, &(record->header));
  59.  
  60.   strncpy(record->templatename, windowname, wimp_MAXNAME);
  61.   record->templatename[wimp_MAXNAME] = 0;       /* Record of name for help   */
  62.  
  63.   record->window = window;                      /* Remember window handle    */
  64.   record->memory = windowptr;                   /* remember to dealloc later */
  65.  
  66.   return(window);
  67. }
  68.  
  69.